<?php
/********************************************************
** Copyright 2010-2013. Todos los derechos reservados. **
** Desarrollado y Gestionado por:					   **
** Sugey Quintero (Analista)						   **
** José G. De Freitas (Programador)					   **
** Klaudia Uribe (Diseñadora Web)					   **
** Cesar Isturiz (Diseñador Web)					   **
**				S E A  v1.0							   **
*********************************************************/

session_start();
include("conexion2.php");

	if (isset($_SESSION['name']) and isset($_SESSION['tiempo'])) {
        include("Tiempo.php");
		date_default_timezone_set('America/Caracas'); setlocale(LC_TIME, 'spanish');
		$usuario = $_SESSION['name'];
		$fecha = date("Y-m-d H:i:s");
		$auditoria = mysql_query("INSERT INTO auditoria SELECT '$usuario', '$fecha' , 'Datos generales del profesor liceo' ");

    }else {
		echo "<script>alert('Debe ingresar al sistema primero');</script>";
		echo "<script>document.location.href='index.php';</script>";
	}
include("conexion.php");
	
$cedula_p=$_GET['cedula_p'];
$existe=mysql_fetch_row(mysql_query("SELECT * FROM profesor WHERE CI_p='$cedula_p' "));
	if($existe > 0){
		$sql=mysql_query("select * from profesor where CI_p='$cedula_p' ");
		$row=mysql_fetch_array($sql);

		$prof = mysql_fetch_array(mysql_query("SELECT Materia_Cod_m, periodo FROM profesor_has_materia WHERE Profesor_CI_p='$cedula_p' ORDER BY periodo DESC"));
		$codmat = substr($prof[0], 0, -2);
		$sql_m = mysql_query("SELECT nombre_m, ano_m FROM materia WHERE Cod_m IN ($codmat) ");
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Datos del profesor</title>
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico">
<link href="style.css" rel="stylesheet" type="text/css" />
<!-- calendario-->
<link rel="stylesheet" type="text/css" href="src/css/jscal2.css" />
<link rel="stylesheet" type="text/css" href="src/css/border-radius.css" />
<link rel="stylesheet" type="text/css" href="src/css/steel/steel.css" />
<script type="text/javascript" src="src/js/jscal2.js"></script>
<script type="text/javascript" src="src/js/lang/es.js"></script>
<!-- fin calendario-->
<!-- botones-->
<link type="text/css" href="js/css/smoothness/jquery-ui-1.8.16.custom.css" rel="Stylesheet" />      
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script>
<script src="js/prototype.js" type="text/javascript"></script>
<script language="JavaScript" src="js/valida_p.js"></script>
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){
j$(".button").button();
});

j$(function(){
	j$('#menu li a').click(function(event){
		var elem = j$(this).next();
		if(elem.is('ul')){
			event.preventDefault();
			j$('#menu ul:visible').not(elem).slideUp();
			elem.slideToggle();
		}
	});
});

function habilitar(form) {
  for (i=0; ele = form.elements[i]; i++)
    if (ele.type == 'text')
      ele.disabled = false;
      document.getElementById('cambiar').style.display="inline";
	alert('Campos habilitados!');
}

//copiar de select a campo texto
oldvalue = "";
function passText(passedvalue) {
  if (passedvalue != "") {
    var totalvalue = oldvalue+passedvalue+", ";
    document.profe.materias.value = totalvalue;
    oldvalue = document.profe.materias.value;
  }
}

function comprobar_p()
{  
  var url = 'http://127.0.0.1/sistema/sistema_liceo/comprobar_p.php';
  var pars= ('cedula_p=' + document.getElementById('cedula_p').value);
  var myAjax = new Ajax.Updater( 'comprobar_mensaje_p', url, { method: 'get', parameters: pars});
}

function verifyInput(_selList,_textBox,pos) {
	document.getElementById('cedula_p').readOnly = false;
	var SI = eval(_selList+".selectedIndex");
	var SV = eval(_selList+".options[SI].value");
	eval(_textBox+".value = SV");
	var a = eval(_selList+".options.selectedIndex=0");
	if (pos=='0'){
		document.buscador.cedula_p.focus();
	}
}
</script>
<!-- fin botones-->
</head>

<body>
<div id="wrap">
<div id="header">
<div id="hora">
<?php include("Hora.php"); ?>
</div>
<div id="topnav">
	<?php include("MenuSuperior.php"); ?>
</div>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h">

</div>

<div class="postcontent">

<blockquote><h2 align="center">DATOS DEL PROFESOR</h2></blockquote>
	<fieldset>
	<legend align=left><b><font size=2>BUSCADOR</font></b></legend>
		<form action=datos_gen_p.php method=get name=buscador>
		<table width=100% cellspacing=3 cellpadding=0 border=0>
			<tr>
				<td width=50% align=center>C&eacute;dula: <select name='Nac_p' onchange="verifyInput('document.buscador.Nac_p','document.buscador.cedula_p','0')"><option></option><option value='V-'>V-</option><option value='E-'>E-</option></select><input name='cedula_p' id='cedula_p' onKeyUp='comprobar_p(this.value)' onKeyPress='return acceptNum(event)' size=8 maxlength=10 readonly>
				<input class=button type=submit value=Buscar><br><span id="comprobar_mensaje_p"></span></td>
			</tr>
		</table>
		</form>
	</fieldset>

<div class="post">
<span></span></div>

<?php include("conexion.php");
if ($sql){
	echo "
		<fieldset>
		<legend align=left><b><font size=2>PROFESOR</font></b></legend>
			<form action=res_datos_g_p.php method=POST>
			<table width=100% cellspacing=3 cellpadding=0 border=0>
				<tr>
					<td width=50%>C&eacute;dula: </td><td><input name=cedula_p size=8 maxLength=8 id=cedula_p value='$row[0]' disabled></td>
				</tr>
				<tr>
					<td>Nombres: </td><td><input type=text name=nombre size=35 value='$row[1]' disabled></td>
				</tr>
				<tr>	
					<td>Apellidos: </td><td><input type=text name=apellido size=35 value='$row[2]' disabled></td>
				</tr>
				<tr>
					<td>Lugar de Nac.: </td><td><input type=text name=lugar_nac size=35 value='$row[3]' disabled></td>		
				</tr>
				<tr>	
					<td>Fecha de Nac.: </td><td><input type=text name=f_nac size=35 value='$row[4]' disabled></td>
				</tr>
				<tr>	
					<td>Sexo: </td><td><input type=text name=sexo size=2 value='$row[5]' disabled></td>
				</tr>
				<tr>
					<td>Direcci&oacute;n: </td><td><input type=text name=direc size=35 value='$row[6]' disabled></td>
				</tr>
				<tr>
					<td>Tel&eacute;fono Casa: </td><td><input type=text name=tlfo_c size=12 value='$row[9]' disabled>&nbsp;&nbsp;&nbsp;
				</tr>
				<tr>	
					<td>Tel&eacute;fono Movil: </td><td><input type=text name=tlfo_m size=12 value='$row[10]' disabled></td>
				<tr>
				<tr>
					<td>Gu&iacute;a de Grado/Secci&oacute;n: </td><td><input type=text name=grado  size=5 value='$row[7]' disabled>/<input type=text name=sec size=1 value='$row[8]' disabled></td>
				</tr>
				</table>
				
				<div id=cambiar style='display: none;'>
					<table width=100% cellspacing=3 cellpadding=0 border=0>
					<td width=50%>Cambiar Grado/Secci&oacute;n </td><td><select name=ano><option></option><option value='1er Ano'>1er A&ntilde;o</option><option value='2do Ano'>2do A&ntilde;o</option><option value='3er Ano'>3er A&ntilde;o</option></select><select name=seccion><option></option><option>A</option><option>B</option></select></td>
					</table>
				</div>
				
				<table width=100% cellspacing=3 cellpadding=0 border=0>
				<tr>
					<td width=50%>Titulo: </td><td><input type=text name=aprobo size=35 value='$row[11]' disabled></td>
				</tr>
				<tr>	
					<td>A&ntilde;o de Ingreso </td><td><input type=text name=ano_ing size=4 maxlength=4 value='$row[12]' disabled></td>
				</tr>
				<tr>	
					<td>Ultimo periodo dictado </td><td>$prof[1]</td>
				</tr>
				<tr>
					<td>Materias a dictar: </td><td>";
				while($materias=mysql_fetch_array($sql_m)){
					echo "$materias[0], $materias[1] a&ntilde;o<br>";
				}
				echo "</td>
				</tr>
			</table>
		</fieldset>

<div class=post>
<span></span></div>

<div id=botonera align=center>
	<input class=button type=button value=Modificar onclick='habilitar(this.form)'>
	<input class=button type=submit value=Guardar>
	<input class=button type=button value=Cancelar onClick=location='index.php'>
</div>
</form>";
	
} ?>

</div>
<div class="post_b">
<span></span></div>
</div>


</div>

<div class="post">
<div class="post_h">

</div>


</div>

<?php include("Menu.php"); ?>

<div class="clear"></div>
</div>
<div id="pagebottom"></div>

<div id="footer">
<P>&reg; Derechos Reservados @ CopyRight. 2011-2012</P>
<p>Programadores: Quintero E, Isturiz C, Uribe C, De Freitas J.</p>
</div>
</div>
</body>
</html>
